package com.xbongbong.paas.model.impl;

import com.alibaba.fastjson.JSONArray;
import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.domain.dao.PaasProcessDataDao;
import com.xbongbong.paas.domain.dao.PaasProcessTaskDao;
import com.xbongbong.paas.domain.entity.PaasProcessDataEntity;
import com.xbongbong.paas.domain.entity.PaasProcessTaskEntity;
import com.xbongbong.paas.enums.DelEnum;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.enums.FlowStatusEnum;
import com.xbongbong.paas.enums.PaymentSheetTypeEnum;
import com.xbongbong.paas.model.PaasProcessDataModel;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.CommentUtil;
import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.paas.toolbox.util.StringUtil;
import com.xbongbong.paas.util.ExplainUtil;
import com.xbongbong.pro.constant.BusinessConstant;
import com.xbongbong.pro.domain.entity.UpdateDataEntity;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.enums.business.PaymentSheetEnum;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * @author: wufeng
 * @date: 2018/11/19 14:41
 * @desrcption: 流程任务
 */
@Service("paasProcessDataModel")
public class PaasProcessDataModelImpl implements PaasProcessDataModel {

    private static final String COLUMNS = "id,corpid,app_id,menu_id,form_id,form_data_id,template_id,task_id,flow_status,`data`,saas_need_pojo,owner_id,department_id,serial_no,creator_id,add_time,update_time,del,saas_mark,business_type,sub_business_type,post_position";

    @Resource
    private PaasProcessDataDao paasProcessDataDao;
    @Resource
    private PaasProcessTaskDao paasProcessTaskDao;

    @Override
    public Integer insert(PaasProcessDataEntity entity) {
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return paasProcessDataDao.insert(entity);
    }

    @Override
    public List<PaasProcessDataEntity> list(Map<String, Object> entity) {
        if (!entity.containsKey("columns")) {
            entity.put("columns", new StringBuffer(COLUMNS));
        }
        return paasProcessDataDao.findEntitys(entity);
    }

    @Override
    public PaasProcessDataEntity getByKey(Integer key, String corpid) {
        return paasProcessDataDao.getByKey(key, corpid);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> entity) {
        return paasProcessDataDao.getEntitysCount(entity);
    }

    /**
     * 根据data里某个条件搜索
     *
     * @param dataParam   data里属性
     * @param param 参数
     */
    @Override
    public Integer getCountByCondition(Map<String, Object> dataParam, Map<String, Object> param) {
        Map<String, Object> dataMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        for (Map.Entry<String, Object> entry : dataParam.entrySet()) {
            String key = entry.getKey();
            dataMap.put("$." + key, entry.getValue());
        }
        return paasProcessDataDao.getCountByCondition(dataMap, param);
    }

    @Override
    public Integer delete(PaasProcessDataEntity entity) {
        return paasProcessDataDao.deleteByKey(entity.getId().intValue(), entity.getCorpid());
    }

    @Override
    public Integer update(PaasProcessDataEntity entity) {
        long now = DateUtil.getInt();
        entity.setUpdateTime(now);
        return paasProcessDataDao.update(entity);
    }

    /**
     * 没写mapper
     * @param entityList
     */
    @Override
    public void insertBatch(List<PaasProcessDataEntity> entityList) {
        paasProcessDataDao.insertBatch(entityList);
    }

    @Override
    public PaasProcessDataEntity getByTaskId(Long key, String corpid) {
        return paasProcessDataDao.getByTaskId(key, corpid);
    }

    @Override
    public List<PaasProcessDataEntity> getInApprovalDataByIdCondition(int businessType, String attr, List<Long> dataIdIn, String corpid, List<Integer> flowStatusIn) {
        Map<String,Object> param = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        param.put("corpid",corpid);
        param.put("saasMark",SaasMarkEnum.SAAS.getCode());
        param.put("businessType",businessType);
        param.put("flowStatusIn",flowStatusIn);
        param.put("del", DelEnum.NORMAL.getDel());
        attr = "$." + attr;
        List<Object> dataIdStrList = JSONArray.parseArray(JSONArray.toJSONString(dataIdIn),Object.class);
        List<PaasProcessDataEntity> paasProcessDataEntityList = new ArrayList<>();
        if (CollectionUtils.isNotEmpty(dataIdStrList)) {
            paasProcessDataEntityList = paasProcessDataDao.getInApprovalDataByIdCondition(param, attr, dataIdStrList);
        }
        // 为了保证数据的一致性，所以查一遍task表，确保任务已删除
        Map<Long, PaasProcessDataEntity> dataMap = new HashMap<>(paasProcessDataEntityList.size());
        if (paasProcessDataEntityList.isEmpty()) {
            return paasProcessDataEntityList;
        }
        List<Long> taskIdIn = new ArrayList<>();
        paasProcessDataEntityList.forEach(item -> {
            dataMap.put(item.getTaskId(), item);
            taskIdIn.add(item.getTaskId());
        });
        param.clear();
        param.put("corpid", corpid);
        param.put("idIn", taskIdIn);
        param.put("del",  DelEnum.DELETE.getDel());
        List<PaasProcessTaskEntity> processTaskEntityList = paasProcessTaskDao.findEntitys(param);
        for (PaasProcessTaskEntity paasProcessTaskEntity : processTaskEntityList) {
            paasProcessDataEntityList.remove(dataMap.get(paasProcessTaskEntity.getId()));
        }
        return paasProcessDataEntityList;
    }

    @Override
    public void deleteByTaskId(Long taskId, String corpid) {
        paasProcessDataDao.deleteByTaskId(taskId, corpid);
    }

    @Override
    public List<PaasProcessDataEntity> getInApprovalDataByCondition(Long formId, int businessType, String attr, String name, String corpid) {
        Map<String,Object> param = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        CommentUtil.addToMap(param,"formId",formId);
        param.put("corpid",corpid);
        param.put("saasMark",SaasMarkEnum.SAAS.getCode());
        param.put("businessType",businessType);
        param.put("flowStatusIn",Arrays.asList(FlowStatusEnum.APPROVAL_PENDING.getType(),FlowStatusEnum.IN_APPROVAL.getType()));
        param.put("del",DelEnum.NORMAL.getDel());
        attr = "$." + attr;
        List<PaasProcessDataEntity> paasProcessDataEntityList = paasProcessDataDao.getInApprovalDataByCondition(param, attr, name);
        // 为了保证数据的一致性，所以查一遍task表，确保任务已删除
        Map<Long, PaasProcessDataEntity> dataMap = new HashMap<>(paasProcessDataEntityList.size());
        if (paasProcessDataEntityList.isEmpty()) {
            return paasProcessDataEntityList;
        }
        List<Long> taskIdIn = new ArrayList<>();
        paasProcessDataEntityList.forEach(item -> {
            dataMap.put(item.getTaskId(), item);
            taskIdIn.add(item.getTaskId());
        });
        param.clear();
        param.put("corpid", corpid);
        param.put("idIn", taskIdIn);
        param.put("del",  DelEnum.DELETE.getDel());
        List<PaasProcessTaskEntity> processTaskEntityList = paasProcessTaskDao.findEntitys(param);
        for (PaasProcessTaskEntity paasProcessTaskEntity : processTaskEntityList) {
            paasProcessDataEntityList.remove(dataMap.get(paasProcessTaskEntity.getId()));
        }
        return paasProcessDataEntityList;
    }

    @Override
    public List<PaasProcessDataEntity> getInApprovalDataByLikeCondition(int businessType, String attr, String nameLike, String corpid, Long formId) {
        Map<String,Object> param = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        param.put("corpid",corpid);
        param.put("saasMark",SaasMarkEnum.SAAS.getCode());
        if (Objects.nonNull(formId)){
            param.put("formId", formId);
        }
        param.put("businessType",businessType);
        param.put("flowStatusIn",Arrays.asList(FlowStatusEnum.APPROVAL_PENDING.getType(),FlowStatusEnum.IN_APPROVAL.getType()));
        param.put("del",DelEnum.NORMAL.getDel());
        param.put("startGroup",0);
        param.put("pageNumGroup",10);
        attr = "$." + attr;
        nameLike = nameLike.replace("%","\\%");
        nameLike = nameLike.replace("_","\\_");
        nameLike = "%" + nameLike + "%";
        List<PaasProcessDataEntity> paasProcessDataEntityList = paasProcessDataDao.getInApprovalDataByLikeCondition(param, attr,nameLike);
        // 为了保证数据的一致性，所以查一遍task表，确保任务已删除
        Map<Long, PaasProcessDataEntity> dataMap = new HashMap<>(paasProcessDataEntityList.size());
        if (paasProcessDataEntityList.isEmpty()) {
            return paasProcessDataEntityList;
        }
        List<Long> taskIdIn = new ArrayList<>();
        paasProcessDataEntityList.forEach(item -> {
            dataMap.put(item.getTaskId(), item);
            taskIdIn.add(item.getTaskId());
        });
        param.clear();
        param.put("corpid", corpid);
        param.put("idIn", taskIdIn);
        param.put("del",  DelEnum.DELETE.getDel());
        List<PaasProcessTaskEntity> processTaskEntityList = paasProcessTaskDao.findEntitys(param);
        for (PaasProcessTaskEntity paasProcessTaskEntity : processTaskEntityList) {
            paasProcessDataEntityList.remove(dataMap.get(paasProcessTaskEntity.getId()));
        }
        return paasProcessDataEntityList;
    }

    @Override
    public List<PaasProcessDataEntity> getInApprovalData(int businessType, String attr, String value, String corpid) {
        Map<String,Object> param = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        param.put("corpid",corpid);
        param.put("saasMark",SaasMarkEnum.SAAS.getCode());
        param.put("businessType",businessType);
        param.put("flowStatusIn",Arrays.asList(FlowStatusEnum.APPROVAL_PENDING.getType(),FlowStatusEnum.IN_APPROVAL.getType()));
        param.put("del",DelEnum.NORMAL.getDel());
        param.put("start",0);
        param.put("pageNum",10);
        attr = "$." + attr;
        List<PaasProcessDataEntity> paasProcessDataEntityList = paasProcessDataDao.getInApprovalData(param, attr, value);
        // 为了保证数据的一致性，所以查一遍task表，确保任务已删除
        Map<Long, PaasProcessDataEntity> dataMap = new HashMap<>(paasProcessDataEntityList.size());
        if (paasProcessDataEntityList.isEmpty()) {
            return paasProcessDataEntityList;
        }
        List<Long> taskIdIn = new ArrayList<>();
        paasProcessDataEntityList.forEach(item -> {
            dataMap.put(item.getTaskId(), item);
            taskIdIn.add(item.getTaskId());
        });
        param.clear();
        param.put("corpid", corpid);
        param.put("idIn", taskIdIn);
        param.put("del",  DelEnum.DELETE.getDel());
        List<PaasProcessTaskEntity> processTaskEntityList = paasProcessTaskDao.findEntitys(param);
        for (PaasProcessTaskEntity paasProcessTaskEntity : processTaskEntityList) {
            paasProcessDataEntityList.remove(dataMap.get(paasProcessTaskEntity.getId()));
        }
        return paasProcessDataEntityList;
    }


    @Override
    public List<PaasProcessDataEntity> getInApprovalDataByFormId(int businessType, String attr, String value, String corpid, Long formId) {
        Map<String,Object> param = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        param.put("corpid",corpid);
        param.put("saasMark",SaasMarkEnum.SAAS.getCode());
        param.put("businessType",businessType);
        param.put("formId", formId);
        param.put("flowStatusIn",Arrays.asList(FlowStatusEnum.APPROVAL_PENDING.getType(),FlowStatusEnum.IN_APPROVAL.getType()));
        param.put("del",DelEnum.NORMAL.getDel());
        param.put("start",0);
        param.put("pageNum",10);
        attr = "$." + attr;
        List<PaasProcessDataEntity> paasProcessDataEntityList = paasProcessDataDao.getInApprovalData(param, attr, value);
        // 为了保证数据的一致性，所以查一遍task表，确保任务已删除
        Map<Long, PaasProcessDataEntity> dataMap = new HashMap<>(paasProcessDataEntityList.size());
        if (paasProcessDataEntityList.isEmpty()) {
            return paasProcessDataEntityList;
        }
        List<Long> taskIdIn = new ArrayList<>();
        paasProcessDataEntityList.forEach(item -> {
            dataMap.put(item.getTaskId(), item);
            taskIdIn.add(item.getTaskId());
        });
        param.clear();
        param.put("corpid", corpid);
        param.put("idIn", taskIdIn);
        param.put("del",  DelEnum.DELETE.getDel());
        List<PaasProcessTaskEntity> processTaskEntityList = paasProcessTaskDao.findEntitys(param);
        for (PaasProcessTaskEntity paasProcessTaskEntity : processTaskEntityList) {
            paasProcessDataEntityList.remove(dataMap.get(paasProcessTaskEntity.getId()));
        }
        return paasProcessDataEntityList;
    }

    @Override
    public void updateBatch(List<PaasProcessDataEntity> list, String corpid) {
        paasProcessDataDao.updateBatch(list, corpid);
    }

    @Override
    public void updateBatchForAll(List<PaasProcessDataEntity> list, String corpid) {
        paasProcessDataDao.updateBatchForAll(list, corpid);
    }

    @Override
    public void updateBatchForData(List<UpdateDataEntity> List, String corpid){
        paasProcessDataDao.updateBatchForData(List, corpid);
    }
    /**
     * 根据idlist获取合同相关联的回款单列表
     * @param businessType
     * @param attr
     * @param dataIdIn
     * @param corpid
     * @param flowStatusIn
     * @return
     */
    @Override
    public List<PaasProcessDataEntity> getInApprovalDataByIdConditionJsonArray(int businessType, String attr, List<Long> dataIdIn, String corpid, List<Integer> flowStatusIn) {
        Map<String,Object> param = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        param.put("corpid",corpid);
        param.put("saasMark",SaasMarkEnum.SAAS.getCode());
        param.put("businessType",businessType);
        param.put("flowStatusIn",flowStatusIn);
        param.put("del", DelEnum.NORMAL.getDel());
        attr = "$." + attr;
        List<Object> dataIdStrList = JSONArray.parseArray(JSONArray.toJSONString(dataIdIn),Object.class);
        List<PaasProcessDataEntity> paasProcessDataEntityList = paasProcessDataDao.getInApprovalDataByIdConditionJsonArray(param, attr,dataIdStrList);
        // 为了保证数据的一致性，所以查一遍task表，确保任务已删除
        Map<Long, PaasProcessDataEntity> dataMap = new HashMap<>(paasProcessDataEntityList.size());
        if (paasProcessDataEntityList.isEmpty()) {
            return paasProcessDataEntityList;
        }
        List<Long> taskIdIn = new ArrayList<>();
        paasProcessDataEntityList.forEach(item -> {
            dataMap.put(item.getTaskId(), item);
            taskIdIn.add(item.getTaskId());
        });
        param.clear();
        param.put("corpid", corpid);
        param.put("idIn", taskIdIn);
        param.put("del",  DelEnum.DELETE.getDel());
        List<PaasProcessTaskEntity> processTaskEntityList = paasProcessTaskDao.findEntitys(param);
        for (PaasProcessTaskEntity paasProcessTaskEntity : processTaskEntityList) {
            paasProcessDataEntityList.remove(dataMap.get(paasProcessTaskEntity.getId()));
        }
        return paasProcessDataEntityList;
    }

    /**
     * 根据idlist获取发票列表
     * @param businessType
     * @param attr
     * @param dataIdIn
     * @param corpid
     * @param flowStatusIn
     * @return
     */
    @Override
    public List<PaasProcessDataEntity> getInvoiceInApprovalDataByIdConditionJsonArray(int businessType, String attr, List<Long> dataIdIn, String corpid, List<Integer> flowStatusIn) {
        Map<String,Object> param = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        param.put("corpid",corpid);
        param.put("saasMark",SaasMarkEnum.SAAS.getCode());
        param.put("businessType",businessType);
        param.put("flowStatusIn",flowStatusIn);
        param.put("del", DelEnum.NORMAL.getDel());
        attr = "$." + attr;
        List<String> dataIdStrList = JSONArray.parseArray(JSONArray.toJSONString(dataIdIn),String.class);
        List<PaasProcessDataEntity> paasProcessDataEntityList = paasProcessDataDao.getInvoiceInApprovalDataByIdConditionJsonArray(param, attr,dataIdStrList);
        // 为了保证数据的一致性，所以查一遍task表，确保任务已删除
        Map<Long, PaasProcessDataEntity> dataMap = new HashMap<>(paasProcessDataEntityList.size());
        if (paasProcessDataEntityList.isEmpty()) {
            return paasProcessDataEntityList;
        }
        List<Long> taskIdIn = new ArrayList<>();
        paasProcessDataEntityList.forEach(item -> {
            dataMap.put(item.getTaskId(), item);
            taskIdIn.add(item.getTaskId());
        });
        param.clear();
        param.put("corpid", corpid);
        param.put("idIn", taskIdIn);
        param.put("del",  DelEnum.DELETE.getDel());
        List<PaasProcessTaskEntity> processTaskEntityList = paasProcessTaskDao.findEntitys(param);
        for (PaasProcessTaskEntity paasProcessTaskEntity : processTaskEntityList) {
            paasProcessDataEntityList.remove(dataMap.get(paasProcessTaskEntity.getId()));
        }
        return paasProcessDataEntityList;
    }

    /**
     * 仅用于资金管理第一期上线脚本,查询公司所有的审批记录
     * @param corpid
     * @return
     */
    @Override
    public List<PaasProcessDataEntity> getAllData(String corpid,Integer del) {
        return paasProcessDataDao.getAllData(corpid, del);
    }

    /**
     * 查询客户是否有存在审批中的回款单
     * @param businessType
     * @param attr
     * @param dataIdIn
     * @param corpid
     * @param flowStatusIn
     * @return
     */
    @Override
    public List<PaasProcessDataEntity> getInApprovalDataByIdAndTypeCondition(int businessType, String attr, List<Long> dataIdIn, String corpid, List<Integer> flowStatusIn) {
        Map<String,Object> param = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        param.put("corpid",corpid);
        param.put("saasMark",SaasMarkEnum.SAAS.getCode());
        param.put("businessType",businessType);
        param.put("flowStatusIn",flowStatusIn);
        param.put("del", DelEnum.NORMAL.getDel());
        attr = "$." + attr;
        String type = "$."+ PaymentSheetEnum.PAYMENT_SHEET_TYPE.getAttr();
        List<Object> dataIdStrList = JSONArray.parseArray(JSONArray.toJSONString(dataIdIn),Object.class);
        List<PaasProcessDataEntity> paasProcessDataEntityList = paasProcessDataDao.getInApprovalDataByIdAndTypeCondition(param, attr, dataIdStrList, type, Arrays.asList(PaymentSheetTypeEnum.RED_PREPAYMENT.getCode(),PaymentSheetTypeEnum.PREPAYMENT.getCode()));
        // 为了保证数据的一致性，所以查一遍task表，确保任务已删除
        Map<Long, PaasProcessDataEntity> dataMap = new HashMap<>(paasProcessDataEntityList.size());
        if (paasProcessDataEntityList.isEmpty()) {
            return paasProcessDataEntityList;
        }
        List<Long> taskIdIn = new ArrayList<>();
        paasProcessDataEntityList.forEach(item -> {
            dataMap.put(item.getTaskId(), item);
            taskIdIn.add(item.getTaskId());
        });
        param.clear();
        param.put("corpid", corpid);
        param.put("idIn", taskIdIn);
        param.put("del",  DelEnum.DELETE.getDel());
        List<PaasProcessTaskEntity> processTaskEntityList = paasProcessTaskDao.findEntitys(param);
        for (PaasProcessTaskEntity paasProcessTaskEntity : processTaskEntityList) {
            paasProcessDataEntityList.remove(dataMap.get(paasProcessTaskEntity.getId()));
        }
        return paasProcessDataEntityList;
    }

    @Override
    public Integer updateInstockAndOutstockType(List<UpdateDataEntity> list) throws XbbException {
        return paasProcessDataDao.updateInstockAndOutstockType(list);
    }

    @Override
    public Integer deleteByFormId(Long formId, String corpid) {
        return paasProcessDataDao.deleteByFormId(formId, corpid);
    }

    @Override
    public List<String> getCorpidList(Integer businessType) {
        return paasProcessDataDao.getCorpidList(businessType);
    }

    @Override
    public Integer getByFundAccountIdInPaymentSheet(String corpid, Long accountId) {
        return paasProcessDataDao.getByFundAccountIdInPaymentSheet(corpid, accountId);
    }

    @Override
    public Integer getByFundAccountIdInPaySheet(String corpid, Long accountId) {
        return paasProcessDataDao.getByFundAccountIdInPaySheet(corpid, accountId);
    }

    @Override
    public Integer hasLabelInApprovel(Map<String, Object> param) {
        return paasProcessDataDao.hasLabelInApprovel(param);

    }

    @Override
    public List<PaasProcessDataEntity> hasDataInApproval(Map<String, Object> param) {
        return paasProcessDataDao.hasDataInApproval(param);
    }

    @Override
    public List<PaasProcessDataEntity> hasDataInApprovalWithData(Map<String, Object> param) {
        return paasProcessDataDao.hasDataInApprovalWithData(param);
    }

    @Override
    public Long countDataInApproval(Map<String, Object> param) {
        return paasProcessDataDao.countDataInApproval(param);
    }

    @Override
    public boolean hasDataInApproval(String corpid, Integer saasMark, Integer businessType, Long formId, String attr, String subAttr, Integer fieldType, Integer page, Integer pageSize) {
        String parent;
        if (StringUtil.isNotEmpty(subAttr)) {
            parent = "$."+subAttr+"[*]."+attr;
        }else {
            parent = "$."+attr;
        }
        Map<String, Object> param = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        Object value;
        if (Objects.equals(FieldTypeEnum.LINK_DATA.getType(), fieldType)) {
            // 关联数据，判断字段存在或者非0
            param.put("value", 0);
        } else if (Objects.equals(FieldTypeEnum.ADDRESS.getType(), fieldType)
                || Objects.equals(FieldTypeEnum.LOCATION.getType(), fieldType)) {
            // 地址或者定位
            parent = parent + StringConstant.POINT + BusinessConstant.PROVINCE;
            param.put("value", "");
        } else if (Objects.equals(FieldTypeEnum.COMBO_CHECK.getType(), fieldType)
                || Objects.equals(FieldTypeEnum.CHECKBOX_GROUP.getType(), fieldType)
                || Objects.equals(FieldTypeEnum.USER_GROUP.getType(), fieldType)
                || Objects.equals(FieldTypeEnum.DEPT_GROUP.getType(), fieldType)
                || Objects.equals(FieldTypeEnum.IMAGE.getType(), fieldType)
                || ExplainUtil.isSubForm(fieldType)
        ) {
            param.put("array", 1);
        }  else if (Objects.equals(FieldTypeEnum.UPLOAD.getType(), fieldType)) {
            value = "[]";
            param.put("value", value);
        } else if (!Objects.equals(FieldTypeEnum.NUM.getType(), fieldType)) {
            param.put("value", "");
        }
        param.put("attr", parent);
        param.put(StringConstant.CORPID, corpid);
        param.put(StringConstant.DEL, DelEnum.NORMAL.getDel());
        param.put("formId", formId);
        param.put("businessType", businessType);
        param.put("start", page);
        param.put("pageNum", pageSize);
        List<PaasProcessDataEntity> processDataList = hasDataInApproval(param);
        Integer count = processDataList == null ? 1 : processDataList.size();
        if (count > 0){
            return true;
        }
        return false;
    }
}
